<template>
	<view class="container">
		<view class="money-container" v-if="list.length>0">
			<view class="money-item" v-for="(item,index) in list" :key="index">
				<view class="money-item-left">
					<text class="desc">{{item.desc}}</text>
					<text class="time">{{item.add_time}}</text>
				</view>
				<text class="right">+{{item.money}}元</text>
			</view>
			<u-loadmore :status="hasMore?'loading':'nomore'" />
		</view>
		<view class="empty-container" v-else>
			<u-empty text="暂无相关数据" :icon="emptyIcon"></u-empty>
		</view>
	</view>
</template>

<script>
	var _this
	export default {
		data() {
			return {
				emptyIcon:'https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/common/empty.png',
				list: [],
				pageIndex: 1,
				status: 0,
				hasMore:true
			}
		},
		onLoad(option) {
			_this=this
			if(option.status){
				this.status=option.status
			}
			this.get_list()
		},
		onReachBottom() {
			if(this.hasMore){
				this.pageIndex++
				this.get_list()
			}
		},
		methods: {
			//获取余额明细数据
			async get_list() {
				const params = {
					status: this.status,
					pageIndex: this.pageIndex,
					pageSize: 20,
				}
				const data = await _this.$post('api/td_fh_log_list',params)
				if(data.code==200){
					this.list.push(...data.data.list)
					this.hasMore=data.data.list.length>=params.pageSize
				}else{
					this.hasMore=false
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/static/css/user.scss";
	.container {}
</style>